<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){
            //获取目标canvas
            var can=document.querySelector('canvas');
            //获取画笔
            var context=can.getContext('2d');
            //设置填充颜色
            context.fillStyle='pink';
            //开始路径
            context.beginPath();
            //绘制矩形
            // context.rect(100,100,410,100);
            // context.strokeRect(100,100,410,100);

            context.fillRect(100,100,410,100)
            //关闭路径
            context.closePath();
            //呈现
            // context.stroke();
            //清空指定矩形区域内容
            context.clearRect(255,125,50,50);
        }
    </script>
</head>
<body>
    <canvas style="background-color: aqua;" width="600" height="600"></canvas>
</body>
</html>